import request from '../request'
import { AxiosResponse } from 'axios'
import { LoginFrom } from '@/types/views/login'
import { ResponseData } from '@/types/api/public'
import { LoginSuccess, UserInfo, RouterData } from '@/types/api/login'

type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

/**
 * @desc: 登录
 * @param { Object } data 输入的账号密码
 */
export const login = (data: LoginFrom): ConfigType<LoginSuccess> => {
  return request({
    url: '/login',
    method: 'get',
    params:data
  })
}

/**
 * @desc: 获取用户信息
 * @returns data
 */
export const info = (): ConfigType<UserInfo> => {
  return request({
    url: '/info',
    method: 'get'
  })
}

/**
 * @desc: 获取菜单
 */
export const menu = (): ConfigType<RouterData> => {
  return request({
    url: '/menu',
    method: 'get'
  })
}

/**
 * @desc: 退出登录
 */
 export const logout = (): ConfigType => {
  return request({
    url: '/logout',
    method: 'post'
  })
}
/**
 * @desc: 获取地区列表
 */
 export const arealist = (): ConfigType => {
  return request({
    url: '/area',
    method: 'get'
  })
}
/**
 * @desc: 获取地区详情
 */
 export const areaone = (id:any): ConfigType => {
  return request({
    url: `/area?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 删除地区
 */
 export const areadel = (id:any): ConfigType => {
  return request({
    url: `/darea?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 添加地区
 */
 export const areaadd = (data:any): ConfigType => {
  return request({
    url: `/area`,
    method: 'post',
    data:data
  })
}
/* * @desc: 获取企业会员
* 
*/
export const comlist = (params:any): ConfigType => {
  return request({
    url: '/index/',
    method: 'get',
    params
  })
}
/**
 * @desc: 添加企业会员
 */
export const comadd = (data:any): ConfigType => {
  return request({
    url: '/index/',
    method: 'post',
    data:data
  })
}
/**
 * @desc: 编辑地区
 */
 export const areaedit = (data:any): ConfigType => {
  return request({
    url: `/area?id=${data.id}`,
    method: 'put',
    data:data
  })
}
/**
 * @desc: 获取职位列表
 */
 export const postlist = (): ConfigType => {
  return request({
    url: '/post',
    method: 'get'
  })
}
/**
 * @desc: 获取职位详情
 */
 export const postone = (id:any): ConfigType => {
  return request({
    url: `/post?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 删除职位
 */
 export const postdel = (id:any): ConfigType => {
  return request({
    url: `/dpost?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 添加职位
 */
 export const postadd = (data:any): ConfigType => {
  return request({
    url: `/post`,
    method: 'post',
    data:data
  })
}
/**
 * @desc: 编辑职位
 */
 export const postedit = (data:any): ConfigType => {
  return request({
    url: `/post?id=${data.id}`,
    method: 'put',
    data:data
  })
}
/**
 * @desc: 获取专业列表
 */
 export const majorlist = (): ConfigType => {
  return request({
    url: '/major',
    method: 'get'
  })
}
/**
 * @desc: 获取专业详情
 */
 export const majorone = (id:any): ConfigType => {
  return request({
    url: `/major?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 删除专业
 */
 export const majordel = (id:any): ConfigType => {
  return request({
    url: `/dmajor?id=${id}`,
    method: 'get'
  })
}
/**
 * @desc: 添加专业
 */
 export const majoradd = (data:any): ConfigType => {
  return request({
    url: `/major`,
    method: 'post',
    data:data
  })
}
/**
 * @desc: 编辑专业
 */
 export const majoredit = (data:any): ConfigType => {
  return request({
    url: `/major?id=${data.id}`,

  })
}
/* * @desc: 删除企业会员
 */
export const comdel = (data:any): ConfigType => {
  return request({
    url: `/index/${data.id}`,
    method: 'delete',
  })
}
/**
 * @desc: 企业会员详情
 */
export const comone = (data:any): ConfigType => {
  return request({
    url: `/index/${data.id}`,
    method: 'get',
  })
}
/**
 * @desc: 编辑企业会员
 */
export const comedit = (data:any): ConfigType => {
  return request({
    url: `/index/${data.id}`,
    method: 'put',
    data:data
  })
}